#include<stdio.h>
#include<stdlib.h>
typedef int ElementType;
typedef int Position;
#define MAXN 100+1
struct SNode {
    ElementType *Data;
    Position Top;
    int MaxSize;
};
typedef struct SNode *Stack;

Stack CreateStack(int MaxSize)
{
    Stack S = (Stack)malloc(sizeof(struct SNode));
    S->Data = (ElementType *)malloc(MaxSize * sizeof(ElementType));
    S->Top = -1;
    S->MaxSize = MaxSize;
    return S;
}

int IsFull(Stack S)
{
    return (S->Top == S->MaxSize-1);
}

int Push(Stack S, ElementType X)
{
    if (IsFull(S)) {
        printf("error ");
        return -1;
    }
    else {
        S->Data[++(S->Top)] = X;
        return 1;
    }
}

int IsEmpty(Stack S)
{
    return (S->Top == -1);
}
 
void Pop(Stack S)
{
    if (IsEmpty(S))
        printf("error ");
    else
        printf("%d ", S->Data[(S->Top)--]);
}

int main()
{
    Stack S = CreateStack(MAXN);
    int op, X;
    while(1)
    {
        scanf("%d", &op);
        if(op == -1)
            break;
        else if(!op)
            Pop(S);
        else
        {
            scanf("%d", &X);
            Push(S, X);
        }
    }
    return 0;
}